
function DeletePlayerMark(userID) {
	for (var i = 0; i < markArray.length; i++) {
		var _markObject = markArray[i];
		if (userType == 0) {
			if (_markObject != currrentMark) {
				_markObject.setMap(null);
				_markObject = null;
			}
		} else {
			_markObject.setMap(null);
			_markObject = null;
		}


	}

	markArray = new Array();
}


var admin_isPlayerNameShow = false;
function Admin_SetPlayerNameShow(e) {
	admin_isPlayerNameShow = !admin_isPlayerNameShow;
	if (admin_isPlayerNameShow == true) {
		e.innerHTML = "隐藏名称";
		for (var i = 0; i < markArray.length; i++) {
			var _markObject = markArray[i];
			var markerContent =
				`<div>
				   					<div  class="amap-marker-label1">${_markObject.userName}</div>
				   				   </div>`;

			_markObject.setContent(markerContent);
		}
	} else {
		e.innerHTML = "队友名称";
		for (var i = 0; i < markArray.length; i++) {
			var _markObject = markArray[i];
			var markerContent =
				 `<div>
				                <img src="image/adminplayer/${_markObject.roomIndex}.png" style="width:24px;height:24px"> 
				       </div>`;

			_markObject.setContent(markerContent);
			_markObject.setAngle(_markObject.angle);
		}
	}
	
}
//玩家队友的切换展示
function SetPlayerShow(e) {
	if (isPlayerShow == false) {
		e.innerHTML = "队友隐藏";

		for (var i = 0; i < markArray.length; i++) {
			var _markObject = markArray[i];
			if (_markObject.getExtData() == userId) {
				continue;
			}
			var markerContent =
				`<div>
				   					<div  class="amap-marker-label1">${_markObject.userName}</div>
				   				   </div>`;

			_markObject.setContent(markerContent);
		}
	} else {
		e.innerHTML = "队友显示";

		for (var i = 0; i < markArray.length; i++) {
			var _markObject = markArray[i];
			if (_markObject.getExtData() == userId) {
				continue;
			}
			var markerContent =
				`<div>
					   						<img src="image/locate/locate.png" style="width:24px;height:24px"> 
					   					   </div>`;

			_markObject.setContent(markerContent);
		}
	}
	isPlayerShow = !isPlayerShow;
}

function CreatePlayerMarker(data, _userID) {

	for (var i = 0; i < data.length; i++) {
		//设置玩家图标
		var _item = data[i];
		var url = "image/locate/locate.png";
		var icon;
		if (_userID == _item.userId) {
			url = "image/locate/my.png";
			icon = new AMap.Icon({
				size: new AMap.Size(32, 32), // 图标尺寸
				image: url, // Icon的图像
				imageSize: new AMap.Size(32, 32) // 根据所设置的大小拉伸或压缩图片
			});

		} else {
			var iconSize = 24;
			icon = new AMap.Icon({
				size: new AMap.Size(iconSize, iconSize), // 图标尺寸
				image: url, // Icon的图像
				imageSize: new AMap.Size(iconSize, iconSize) // 根据所设置的大小拉伸或压缩图片
			});
		}

		var _markObject;
		//玩家图标
		if (userType == 0) {
			if (_userID != _item.userId) {
				//根据当前的状态
				if (isPlayerShow == false) {
					_markObject = new AMap.Marker({
						map: map,
						icon: icon,
						position: [_item.lon, _item.lat],

					});

				} else {
					var markerContent =
						`<div>
												<div  class="amap-marker-label1">${_item.userName}</div>
											   </div>`;
					_markObject = new AMap.Marker({
						map: map,
						content: markerContent,
						position: [_item.lon, _item.lat],
					});
				}

				_markObject.setExtData(_item.userId);
				_markObject.userName = _item.userName;
				markArray.push(_markObject);

			}
			//为当前的用户
			else {
				if (!currrentMark) {
					_markObject = new AMap.Marker({
						map: map,
						icon: icon,
						anchor: "top-center",
						//content: content,
						// direction: marker.direction,
						anchor: 'center',
						offset: new AMap.Pixel(0, 0), // 设置点标记偏移量
						position: [_item.lon, _item.lat],
					});

					currentPosition = _markObject.getPosition();
					currrentMark = _markObject;
					_markObject.setExtData(_item.userId);
					//_markObject.userName = _item.userName;
					markArray.push(_markObject);

				}
			}
		} 
		//管理端
		else {
			//显示管理员的名称
			var markerContent ="";
			if(admin_isPlayerNameShow)
			{
				markerContent = `<div>
											<div  class="amap-marker-label1">${_item.userName}</div>
										   </div>`;
			}
			//只显示图标的名称
			else{
				markerContent =
					`<div>
					                <img src="image/adminplayer/${_item.roomIndex}.png" style="width:24px;height:24px"> 
					       </div>`;
				
			}
			_markObject = new AMap.Marker({
				map: map,
				position: [_item.lon, _item.lat],
			});
			_markObject.setContent(markerContent);
			_markObject.userName = _item.userName;
			_markObject.roomIndex = _item.roomIndex;
			_markObject.angle = _item.angle;
			markArray.push(_markObject);
			//设置角度
			if(!admin_isPlayerNameShow)
			{
				_markObject.setAngle(_item.angle);
			}
			// var clickHandle = AMap.event.addListener(_markObject, 'click', function(e) {
			// 	this.lifeUserName = _item.userName;
			// 	this.lifeuserId = _item.userId;
			// });
			
		}
	}

}